Returns a list of all Tasks in a given Folder and all subfolders.
#Include <TaskScheduler.au3>
_TS_TaskList($oService[, $vFolder = "\"[, $iShowHidden = 0[, $iShowDisabled = 1[, $iShowMS = 1[, $iProperties = 0[, $bReadable = True]]]]]])
Parameters
| $oService | Task Scheduler Service object as returned by _TS_Open |
| $vFolder | [optional] Task Folder to process either as string Folderpath (e.g. "\test\test2") or Folder object (default = "\" means: root Folder) |
| $iShowHidden | [optional] Returns hidden Tasks as well when set to 1 (default = 0) |
| $iShowDisabled | [optional] Returns disabled Tasks as well when set to 1 (default = 1) |
| $iShowMS | [optional] Returns Tasks in Microsoft Folders as well when set to 1 (default = 1) |
| $iProperties | [optional] A bitwise mask that indicates the properties to be returned (default = 0 = all properties) e.g. 5 returns Task name and State. Possible values (to select all 25 possible columns use the maximum value of 2^25 - 1 or 0 (which gets translated to 2^25 - 1): 1 (2^0) - Task name 2 (2^1) - Task Folder 4 (2^2) - State 8 (2^3) - Hidden 16 (2^4) - Last Task result 32 (2^5) - Last run 64 (2^6) - Next run 128 (2^7) - Missed runs 256 (2^8) - Allow demand start 512 (2^9) - AllowHardTerminate 1024 (2^10) - DeleteExpiredTaskAfter 2048 (2^11) - DisallowStartIfOnBatteries 4096 (2^12) - ExecutionTimeLimit 8192 (2^13) - MultipleInstances 16384 (2^14) - Priority 32768 (2^15) - RestartCount 65536 (2^16) - RestartInterval 131072 (2^17) - RunOnlyIfIdle 262144 (2^18) - RunOnlyIfNetworkAvailable 524288 (2^19) - StartWhenAvailable 1048576 (2^20) - StopIfGoingOnBatteries 2097152 (2^21) - WakeToRun 4194304 (2^22) - Author 8388608 (2^23) - Date 16777216 (2^24) - Description |
| $bReadable | [optional] True translates some values (e.g. State to text, date/time to readable format and suppresses empty values). |
Return Value
Success: two-dimensional zero based array with the information requested by parameter $iProperties (see there)
Remarks
None.
Related
Example
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include-once
#include <TaskScheduler.au3>
#include <Array.au3>
AutoItSetOption("MustDeclareVars", 1)
; *****************************************************************************
; Connect to the Task Scheduler Service
; *****************************************************************************
Global $oService = _TS_Open()
If @error <> 0 Then Exit MsgBox($MB_ICONERROR, "Task Scheduler UDF", "Error connecting to the Task Scheduler Service. @error = " & @error & ", @extended = " & @extended & @CRLF & @CRLF & _TS_ErrorText(@error))
; *****************************************************************************
; List all tasks (starting in the root folder). Show hidden and disabled tasks.
; Ignore Microsoft folder. Display Task name, folder, last run time and number of missed runs.
; *****************************************************************************
Global $iProperties = 2^0 + 2^1 + 2^5 + 2^7
Global $aTasks = _TS_TaskList($oService, Default, 1, 1, 0, $iProperties, True)
If Not @error Then
_ArrayDisplay($aTasks, "_TS_TaskList", "", 0, Default, _TS_TaskListHeader($iProperties))
Else
MsgBox($MB_ICONERROR, "_TS_TaskList", "Returned @error=" & @error & ", @extended=" & @extended & @CRLF & @CRLF & _TS_ErrorText(@error))
EndIf
_TS_Close()